<%-- 
    Document   : AddSong
    Created on : Jun 8, 2012, 8:17:39 AM
    Author     : Student
--%>


<%@tag description="put the tag description here" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/style/style.css" />

<script  src="${pageContext.request.contextPath}/js/qaEffect.js"></script>
<script src="${pageContext.request.contextPath}/js/flexiblelist.js"></script>

<%-- The list of normal or fragment attributes can be specified here: --%>
<%@attribute name="message"%>
<%@attribute name="song" required="true" type="model.Song"%>
<jsp:useBean id="daoArtist" scope="page" class="connection.DaoArtist"/>
<jsp:useBean id="daoAlbum" scope="page" class="connection.DaoAlbum"/>
<jsp:useBean id="daoGenre" scope="page" class="connection.DaoGenre"/>
<%-- any content can be specified here e.g.: --%>

<div id="itunewindow">

    <c:if test="${song eq null}">
        <form method="POST" action="${pageContext.request.contextPath}/AddSongController" >

            Song Title       :  
            <input name="txtTitle" type="text"/> 
            <br/>

            Artist  :
            <select name="ddlArtist">
                <c:forEach items="${daoArtist.retrieveGetArtist()}" var="artist">
                    <option value="${artist.artistId}"> 
                        ${artist.name}
                    </option>
                </c:forEach>
            </select>
            <br/>

            Album  :
            <select name="ddlAlbum">
                <c:forEach items="${daoAlbum.retrieveGetAlbumBy()}" var="album">
                    <option value="${album.albumId}"> 
                        ${album.albumName}
                    </option>
                </c:forEach>
            </select>
            <br/>

            Genre  :
            <select name="ddlGenre">
                <c:forEach items="${daoGenre.retrieveGetGenre()}" var="genre">
                    <option value="${genre.genreId}"> 
                        ${genre.genre}
                    </option>
                </c:forEach>
            </select>
            <br/>

            Date Released (yyyy-MM-dd):
            <input name="txtDateReleased" type="text"/> 
            <br/>

            Price: 
            <input name="txtPrice" type="text"/> 
            <br/>
            Lyrics: 
            <textarea name="taLyrics" rows="10" cols="60" lang="html" >
            </textarea>
            <br/>

            <input type="submit" value="Add" name="btnSubmit"/>

        </form>

    </c:if>

    <c:if test="${song ne null}">
        Editing [${song.title}]
        <form method="POST" action="${pageContext.request.contextPath}/AddSongController" >

            Song Title       :  
            <input name="txtTitle" type="text" value="${song.title}"/> 
            <br/>

            Artist  :
            <select name="ddlArtist" >
                <c:forEach items="${daoArtist.retrieveGetArtist()}" var="artist">

                    <c:if test="${song.artist ne artist.name}">
                        <option value="${artist.artistId}"> 
                            ${artist.name}
                        </option>
                    </c:if>
                    <c:if test="${song.artist eq artist.name}">
                        <option value="${artist.artistId}" selected="selected"> 
                            ${artist.name}
                        </option>
                    </c:if>

                </c:forEach>
            </select>
            <br/>

            Album  :
            <select name="ddlAlbum">
                <c:forEach items="${daoAlbum.retrieveGetAlbumBy()}" var="album">
                    <c:if test="${song.album ne album.albumName}">
                    <option value="${album.albumId}"> 
                        ${album.albumName}
                    </option>
                    </c:if>
                    <c:if test="${song.album eq album.albumName}">
                        <option value="${album.albumId}" selected="selected"> 
                        ${album.albumName}
                    </option>
                    </c:if>
                    
                </c:forEach>
            </select>
            <br/>


            Genre  :
            <select name="ddlGenre">
                <c:forEach items="${daoGenre.retrieveGetGenre()}" var="genre">
                    <c:if test="${song.genre ne genre.genre}">
                        <option value="${genre.genreId}"> 
                            ${genre.genre}
                        </option>
                    </c:if>
                    <c:if test="${song.genre eq genre.genre}">
                        <option value="${genre.genreId}" selected="selected"> 
                            ${genre.genre}
                        </option>
                    </c:if>
                </c:forEach>
            </select>
            <br/>

            Date Released (yyyy-MM-dd):
            <input name="txtDateReleased" type="text" value="${song.dateReleased}" /> 
            <br/>

            Price: 
            <input name="txtPrice" type="text" value="${song.price}"/> 
            <br/>
            Lyrics: 
            <textarea name="taLyrics" rows="10" cols="60" lang="html" >
                ${song.lyrics}
            </textarea>
            <br/>
            <input type="hidden" name="imageLocation" value="${song.imageLocation}"/>
            <input type="hidden" name="songId" value="${song.songId}"/>


            <input type="submit" value="Update" name="btnSubmit"/>


        </c:if>

    </form>
</div>